package com.ttc.group2.videochat.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.jivesoftware.smack.packet.RosterPacket;

import com.quickblox.chat.model.QBRosterEntry;
import com.quickblox.users.model.QBUser;
import com.ttc.group2.videochat.model.Friend;
import com.ttc.group2.videochat.model.User;

public class FriendUtils {

	public static Friend createFriend(QBRosterEntry rosterEntry) {
		Friend friend = new Friend(rosterEntry.getUserId());
		return friend;
	}

	public static boolean isPendingFriend(QBRosterEntry rosterEntry) {
		return RosterPacket.ItemStatus.subscribe
				.equals(rosterEntry.getStatus());
	}

	public static Friend createFriend(int userId) {
		Friend friend = new Friend(userId);
		return friend;
	}

	public static List<Friend> createFriendsList(
			Collection<QBRosterEntry> rosterEntryCollection) {
		List<Friend> friendsList = new ArrayList<Friend>();
		for (QBRosterEntry rosterEntry : rosterEntryCollection) {
			friendsList.add(createFriend(rosterEntry));
		}
		return friendsList;
	}

	public static ArrayList<Integer> getFriendIdsList(List<QBUser> friendList) {
		ArrayList<Integer> friendIdsList = new ArrayList<Integer>();
		for (QBUser friend : friendList) {
			friendIdsList.add(friend.getId());
		}
		return friendIdsList;
	}

	public static ArrayList<Integer> getFriendIds(List<User> friendList) {
		ArrayList<Integer> friendIdsList = new ArrayList<Integer>();
		for (User friend : friendList) {
			friendIdsList.add(friend.getUserId());
		}
		return friendIdsList;
	}

	public static List<Integer> getUserIdsFromRoster(
			Collection<QBRosterEntry> rosterEntryCollection) {
		List<Integer> userIds = new ArrayList<Integer>();
		for (QBRosterEntry entry : rosterEntryCollection) {
			userIds.add(entry.getUserId());
		}
		return userIds;
	}

}